<%--
  Created by IntelliJ IDEA.
  User: CHJYPC
  Date: 2021/6/19
  Time: 17:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    request.setAttribute("rootPath", basePath);%>
<html>
<head>
    <meta charset="UTF-8">
    <title>签到系统</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script src="${rootPath}resources/js/jquery.min.js"></script>
    <script src="${rootPath}resources/js/index.js"></script>
    <link rel="stylesheet" type="text/css" href="${rootPath}resources/css/index.css">

</head>
<body onload="lbutton('${member}');">
<div class="wrapper" id="divWrapper">
    <div class="header">

        <ul class="menuTreeMain">
            <li><a href="javascript:toMain();">首页</a></li>
            <li><a href="javascript:toMyClazz('${member}');">我的班级</a>
                <ul class="menuTreeSecond">
                    <li><a href="javascript:cerateClass('${member}');">创建班级</a></li>
                    <li><a href="javascript:insertClass('${member}');">加入班级</a></li>
                </ul>
            </li>
        </ul>
        <h2 class="hTitle">签到系统</h2>
        <div class="divloginButton"><a href="javascript:todivLogin();" id="alogin">登录</a></div>
    </div>
    <div class="createClazz">
        <input type="button" value="取消" onclick="closeCreateClazz()">
        <div class="divinput">

            <label class="labelinput" for="clazzName">班级名称： <input type="text" name="clazzName" id="clazzName">
            </label>
            <br><br>
            &emsp;&emsp; &emsp;<input type="button" value="创建" id="createClassButton" style="width: 70px;height: 35px">

        </div>
    </div>
    <div class="insertClazz">
        <input type="button" value="取消" onclick="closeInsertClazz()">
        <div class="divinput">

            <label class="labelinput" for="clazzid">班级编号： <input type="text" name="clazzid" id="clazzid"></label>
            <br><br>
            &emsp;&emsp; &emsp;<input type="submit" value="加入" id="insertClassButton" style="width: 70px;height: 35px">

        </div>
    </div>
    <div class="divlogin">

        <div class="divinput" id="log">
            <div>
                <p class="inputP" onclick="toInputLogin()">&emsp;登录</p>
                <p class="inputP" onclick="toInputRegister()">&emsp;注册</p>
                &emsp;
            </div>
            <div class="divinputSe">
                <br>
                &emsp; <p class="pinput">账号：<input type="text" name="loginid" id="loginid"></p>
                &emsp; &emsp; <p class="pinput">密码：<input type="password" name="loginpaw" id="loginpaw"></p>
                <div class="divinputTr">
                    <input type="button" value="取消" style="width: 70px;height: 35px" onclick="closeLoginView();">
                    <input type="button" id="loginButton" value="登录" style="width: 70px;height: 35px">
                </div>
            </div>
        </div>
        <div class="divinput" id="reg" style="display: none">
            <div>
                <p class="inputP" onclick="toInputLogin()">&emsp;登录</p>
                <p class="inputP" onclick="toInputRegister()">&emsp;注册</p>
                &emsp;
            </div>
            <div class="divinputSe">
                <br>
                &emsp;
                <p class="pinput">账号：<input type="text" name="reid" id="reid"></p>
                &emsp; <p class="pinput">姓名：<input type="text" name="rename" id="rename"></p>
                &emsp; <p class="pinput">密码：<input type="password" name="repaw1" id="repaw1"></p>
                &emsp; <p class="pinput">密码：<input type="password" name="repaw2" id="repaw2"></p>
                <div class="divinputTrSen">
                    <input type="button" value="取消" style="width: 70px;height: 35px" onclick="closeLoginView();">
                    <input type="submit" id="registerButton" value="注册" style="width: 70px;height: 35px">
                </div>
            </div>
        </div>
    </div>

    <div class="main">
        <iframe src="main" class="divChange" id="changeView"></iframe>
    </div>
    <div style="display: none">
        <input type="text" name="requestClazzid" id="requestClazzid">
    </div>
</div>
</body>
<script type="text/javascript">
    function lbutton(member) {
        if (member == "" || member == null || member == undefined) {
            return;
        } else {

            $("#alogin").text("注销");

        }


    }

    //加入班级
    $("#insertClassButton").click(function () {
        var clazzid = $("#clazzid").val();
        if (clazzid == "" || clazzid == null || clazzid == undefined) {
            alert("请输入班级编号")
            return
        }
        $.post("clazzservlet", {
                memberid: ${member.memberid},
                clazzid: clazzid,
                op: "ins"

            },
            function (data, status) {
                var ob = JSON.parse(data);
                alert(ob.meg);
                if (ob.meg == "加入成功") {
                    $(".insertClazz").css({display: "none"});
                }
            });
    });


    //创建班级
    $("#createClassButton").click(function () {
        var name = $("#clazzName").val();
        if (name == "" || name == null || name == undefined) {
            alert("请输入班级名称")
            return
        }
        $.post("clazzservlet", {
                memberid: ${member.memberid},
                classname: name,
                op: "add"

            },
            function (data, status) {
                var ob = JSON.parse(data);
                alert(ob.meg);
                if (ob.meg == "创建成功") {
                    $(".createClazz").css({display: "none"});
                }
            });

    });
</script>
</html>
